package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.Storehouse;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.StorehouseService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/storehouse")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/Storehouse.jsp"),
	@Result(name = "input", location = "/view/Storehouse.jsp")
})

public class StorehouseAction  extends ActionSupport {

  /**
	 */
	private static final long serialVersionUID = -6635711424000200804L;
@Resource
  private StorehouseService storehouseService;
  private   java.lang.Integer dbid ;
  private   java.lang.Integer refPurchaseDbid ;
  private   java.lang.Integer refGoodsDbid ;
  private   java.lang.Integer refShopDbid ;
  private   java.lang.Integer refColorDbid ;
  private   java.lang.Integer refConfigurationDbid ;
  private   java.lang.Integer refUnitDbid ;
  private   java.lang.Integer intype ;
  private   java.lang.Integer status ;
  private   java.lang.Double price ;
  private   java.lang.Double saleprice ;
  private   java.lang.Double money ;
  private   java.lang.Integer number ;
  private   java.lang.String memo ;
  private   java.lang.String serialnumber ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<Storehouse>  storehousePageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public java.lang.Integer getStatus() {
	return status;
}
public void setStatus(java.lang.Integer status) {
	this.status = status;
}
public java.lang.String getSerialnumber() {
	return serialnumber;
}
public void setSerialnumber(java.lang.String serialnumber) {
	this.serialnumber = serialnumber;
}
public java.lang.Integer getRefGoodsDbid() {
	return refGoodsDbid;
}
public void setRefGoodsDbid(java.lang.Integer refGoodsDbid) {
	this.refGoodsDbid = refGoodsDbid;
}
public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.Integer getRefPurchaseDbid() {
   	return this.refPurchaseDbid;
  }
  public void setRefPurchaseDbid(  java.lang.Integer  refPurchaseDbid) {
   	 this.refPurchaseDbid=refPurchaseDbid;
  }
  public    java.lang.Integer getRefShopDbid() {
   	return this.refShopDbid;
  }
  public void setRefShopDbid(  java.lang.Integer  refShopDbid) {
   	 this.refShopDbid=refShopDbid;
  }
  public    java.lang.Integer getRefColorDbid() {
   	return this.refColorDbid;
  }
  public void setRefColorDbid(  java.lang.Integer  refColorDbid) {
   	 this.refColorDbid=refColorDbid;
  }
  public    java.lang.Integer getRefConfigurationDbid() {
   	return this.refConfigurationDbid;
  }
  public void setRefConfigurationDbid(  java.lang.Integer  refConfigurationDbid) {
   	 this.refConfigurationDbid=refConfigurationDbid;
  }
  public    java.lang.Integer getRefUnitDbid() {
   	return this.refUnitDbid;
  }
  public void setRefUnitDbid(  java.lang.Integer  refUnitDbid) {
   	 this.refUnitDbid=refUnitDbid;
  }
  public    java.lang.Integer getIntype() {
   	return this.intype;
  }
  public void setIntype(  java.lang.Integer  intype) {
   	 this.intype=intype;
  }
  public    java.lang.Double getPrice() {
   	return this.price;
  }
  public void setPrice(  java.lang.Double  price) {
   	 this.price=price;
  }
  public    java.lang.Double getSaleprice() {
   	return this.saleprice;
  }
  public void setSaleprice(  java.lang.Double  saleprice) {
   	 this.saleprice=saleprice;
  }
  public    java.lang.Double getMoney() {
   	return this.money;
  }
  public void setMoney(  java.lang.Double  money) {
   	 this.money=money;
  }
  public    java.lang.Integer getNumber() {
   	return this.number;
  }
  public void setNumber(  java.lang.Integer  number) {
   	 this.number=number;
  }
  public    java.lang.String getMemo() {
   	return this.memo;
  }
  public void setMemo(  java.lang.String  memo) {
   	 this.memo=memo;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setStorehousePageBeans(List<Storehouse> storehousePageBeans){
   	 this.storehousePageBeans =storehousePageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<Storehouse> getStorehousePageBeans(){
   	 return this.storehousePageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertStorehouse",results = {@Result(name = "success", type = "json")})
  public String  insertStorehouse() throws Exception{
   	success = false ;
   	info = "" ;
  	Storehouse bean = new Storehouse();
  	bean.setStatus(status);
  	bean.setRefPurchaseDbid(this.refPurchaseDbid); 
  	bean.setSerialnumber(serialnumber);
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefShopDbid(this.refShopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setIntype(this.intype); 
  	bean.setPrice(this.price); 
  	bean.setSaleprice(this.saleprice); 
  	bean.setMoney(this.money); 
  	bean.setNumber(this.number); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	storehouseService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="queryStorehouse",results = {@Result(name = "success", type = "json")})
  public String  queryStorehouse() throws Exception{
  	Storehouse bean = new Storehouse();
  	bean.setStatus(status);
  	bean.setDbid(this.dbid); 
  	bean.setSerialnumber(serialnumber);
  	bean.setRefPurchaseDbid(this.refPurchaseDbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefShopDbid(this.refShopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setIntype(this.intype); 
  	bean.setPrice(this.price); 
  	bean.setSaleprice(this.saleprice); 
  	bean.setMoney(this.money); 
  	bean.setNumber(this.number); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	storehouseService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updateStorehouse",results = {@Result(name = "success", type = "json")})
  public String  updateStorehouse() throws Exception{
   	success = false ;
   	info = "" ;
  	Storehouse bean = new Storehouse();
  	bean.setDbid(this.dbid); 
  	bean.setStatus(status);
  	bean.setSerialnumber(serialnumber);
  	bean.setRefPurchaseDbid(this.refPurchaseDbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefShopDbid(this.refShopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setIntype(this.intype); 
  	bean.setPrice(this.price); 
  	bean.setSaleprice(this.saleprice); 
  	bean.setMoney(this.money); 
  	bean.setNumber(this.number); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
  	
  	bean =storehouseService.selectByPrimaryKey(bean);
  	bean.setStatus(status);
  	bean.setDbid(this.dbid); 
  	bean.setSerialnumber(serialnumber);
  	bean.setRefPurchaseDbid(this.refPurchaseDbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefShopDbid(this.refShopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setIntype(this.intype); 
  	bean.setPrice(this.price); 
  	bean.setSaleprice(this.saleprice); 
  	bean.setMoney(this.money); 
  	bean.setNumber(this.number); 
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	storehouseService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deleteStorehouse",results = {@Result(name = "success", type = "json")})
  public String  deleteStorehouse() throws Exception{
  	Storehouse bean = new Storehouse();
  	bean.setDbid(this.dbid); 
  	bean.setRefPurchaseDbid(this.refPurchaseDbid); 
  	bean.setRefGoodsDbid(this.refGoodsDbid); 
  	bean.setRefShopDbid(this.refShopDbid); 
  	bean.setRefColorDbid(this.refColorDbid); 
  	bean.setRefConfigurationDbid(this.refConfigurationDbid); 
  	bean.setRefUnitDbid(this.refUnitDbid); 
  	bean.setIntype(this.intype); 
  	bean.setPrice(this.price); 
  	bean.setSaleprice(this.saleprice); 
  	bean.setMoney(this.money); 
  	bean.setNumber(this.number); 
  	bean.setStatus(status);
  	bean.setMemo(this.memo); 
  	bean.setCreateDate(this.createDate); 
	storehouseService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }


  @Action(value="listStorehouse",results = {@Result(name = "success", type = "json")})
  public String  listStorehouse() throws Exception{
	  QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	  pageBean.setPageSize( limit );
	  pageBean.setStartCount( start );
	  totalProperty =storehouseService.getTotalRecords( qry, pageBean );
	  storehousePageBeans =storehouseService.getOnePageBeans( qry, pageBean );
	  return SUCCESS;
  }
  
  @Action(value="SubStorehouse",results = {@Result(name = "success",location = "/view/SubStorehouse.jsp")})
  public String  listSubStorehouse() throws Exception{
	  QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	  pageBean.setPageSize( limit );
	  pageBean.setStartCount( start );
	  totalProperty =storehouseService.getTotalRecords( qry, pageBean );
	  storehousePageBeans =storehouseService.getOnePageBeans( qry, pageBean );
	  return SUCCESS;
  }
  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }
  @Action(value="doneSale",results = {@Result(name = "success",location = "/view/Sale.jsp")})
  public String doneSale() throws Exception{
	  return SUCCESS;
  }
  @Action(value="repairManager",results = {@Result(name = "success",location = "/view/repairManager.jsp")})
  public String repairManager() throws Exception{
	  return SUCCESS;
  }

}
